import Vue from 'vue'
import App from './App.vue'
import router from './router'
// 导入axios
import axios from 'axios'
import store from './store'
// 导入element UI
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
// 导入dayjs
import dayjs from 'dayjs'

// 自己的全局样式
import '@/assets/css/global.css' // import locale

import nprogress from 'nprogress'
import 'nprogress/nprogress.css'

// 配置axios
axios.defaults.baseURL = 'http://localhost:8090/'
axios.interceptors.request.use(config => {
  nprogress.start()
  config.headers.Authorization = window.sessionStorage.getItem('token')
  return config
})

axios.interceptors.response.use(config => {
  // console.log(config)
  nprogress.done()
  return config
})
Vue.prototype.$http = axios
Vue.prototype.dayjs = dayjs

Vue.filter('dataFormat', (originVal) => {
  return dayjs(originVal).format('YYYY/MM/DD HH:mm')
})

Vue.use(ElementUI)

Vue.config.productionTip = false

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
